<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.global.js"></script>
</head>
<body>
    <div id="app">
        <p>{{ message }}</p>

        <!-- v-on:click="reverseMessage" -->
        <!-- 给button的click事件绑定处理函数为reverseMessage -->
        <button v-on:click="reverseMessage">反转 Message</button>
    </div>

    <script>
        Vue.createApp({
            data(){
                return {
                    message:"你的圆珠笔"
                }
            },

            // 所有的事件处理函数写在methods节点中
            // 所有函数的this皆为当前组件实例
            methods:{
                reverseMessage(){
                    this.message = this.message.split("").reverse().join("")
                }
            }
        }).mount("#app")
    </script>
</body>
</html>